package com.sskj.run.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.run.bean.AssetAllNewBean;
import com.sskj.run.bean.AssetBean;
import com.sskj.run.bean.BankersMainBean;
import com.sskj.run.bean.CommonBean;
import com.sskj.run.http.HttpConfig;
import com.sskj.run.ui.fragment.BankerJackpotHoldFragment;

import java.util.List;


public class BankerJackpotHoldFragmentPresenter extends BasePresenter<BankerJackpotHoldFragment> {

    public void bankerInOut(String type,String money) {
        httpService.bankerInOut(type,money)
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.msg);
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.bankeInOutSuccess();
                        }
                    }
                });
    }


    /**
     * 公共数据
     */
    public void getCommonData() {
        httpService.getCommonData()
                .tag(this)
                .execute(new JsonCallBack<HttpData<CommonBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<CommonBean>> response) {
                        HttpData httpData = response.body();
//                        ToastUtil.showShort(httpData.msg);
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updataCommonData((CommonBean) httpData.getData());
                        }
                    }
                });
    }


    public void getUserInfo() {
        httpService.getAsset()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<AssetBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<AssetBean>>> response) {
                        HttpData<List<AssetBean>> httpData = response.body();

                        mView.updateMoney(httpData.getData());
                    }
                });
    }

    /**
     * 涨价奖池-主页
     *
     * @param moneyType 币种
     */
    public void getBankerPoolMainMsg(String moneyType) {
        httpService.bankerPoolMain(moneyType)
                .tag(this)
                .retryCount(0)
                .execute(new JsonCallBack<HttpData<BankersMainBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<BankersMainBean>> response) {
                        HttpData httpData = response.body();
//                        ToastUtil.showShort(httpData.msg);
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updataUi((BankersMainBean) httpData.getData());
                        }
                    }
                });
    }



}
